<?php
/**
 *@author Connor <caokang@foxmail.com>
 *@todo
 *@link www.zeevin.com
 */
$tendency = UserSetting::model()->findByPk(Yii::app()->user->id);
$url="&UserSetting[sex_tendency]=$tendency->sex_tendency&UserSetting[age_start]=$tendency->age_start&UserSetting[age_end]=$tendency->age_end&UserSetting[citys_tendency]=$tendency->citys_tendency&UserSetting[edu_tendency]=$tendency->edu_tendency&UserSetting[income_tendency]=$tendency->income_tendency&UserSetting[height]=$tendency->height";
$form = $this->beginWidget('CActiveForm',array(
      'id'=>'search-form',
      'method'=>'GET',
      'action'=>'?r=search'
      ));
      ?>
      <!--main-->
      <div class="warpper">
            <div class="select">
                  <ul>
                        <li> <span class="left">性别：</span>
                              <?php echo CHtml::dropDownList('UserSetting[sex_tendency]', $gets['sex_tendency'], User::getSex());?>

                    </li>
                    <li> <span class="left">年龄：</span>
                        <?php echo CHtml::dropDownList('UserSetting[age_start]', $gets['age_start'], Utils::genAgeSelect());?><span class="left" >~</span>
                        <?php echo CHtml::dropDownList('UserSetting[age_end]', $gets['age_end'], Utils::genAgeSelect());?>
                  </li>
                  <li> <span class="left">城市：</span>
                        <?php echo CHtml::dropDownList('UserSetting[citys_tendency]', $gets['citys_tendency'], Area::getArea(),array('class'=>'selected_city','style'=>'width:50px;'));?>
                  </li>
                  <li> <span class="left">学历：</span>
                        <?php echo CHtml::dropDownList('UserSetting[edu_tendency]', $gets['edu_tendency'], User::getDegree());?> 以上&nbsp;
                  </li>
                  <li> <span class="left">工资：</span>
                        <?php echo CHtml::dropDownList('UserSetting[income_tendency]', $gets['income_tendency'],User::getIncome());?>
                  </li>
                  <li> <span class="left">身高：</span>
                        <?php echo CHtml::dropDownList('UserSetting[height]', $gets['height'], array_combine(range(130, 210),range(130, 210)));?>以上
                  </li>
            </ul>
      </div>
      <?php $this->endWidget();?>
      <div class="person_select">
            <div class="right"> <span class="define_select">定义搜索</span> <span class="conform_select"><a href="?r=search&<?php echo $url;?>">符合自己</a></span></div>
      </div>
</div>
<!--main-->
<div class="warpper">
      <div class="main">
            <div class="page_but">
                  <div class="page">
                        <?php $this->widget('ZLinkPager', array('pages' => $users['pages'])); ?>
                  </div>
            </div>
            <div class="warp_content" style="boder:0px;height:892px;">
                  <div class="warp_list" style="height:892px;">
                        <div class="content" style="height:892px;">
                              <?php if($users['total_num']):?>
                              <?php foreach($users['rows'] as $v):?>
                              <?php 
                              $rs = Yii::app()->db->createCommand()
                              ->select('a.id,a.tag_id,b.tag_name')
                              ->from('user_tags a')
                              ->leftJoin('tags b','a.tag_id=b.id')
                              ->where('a.uid=? and a.type=?',array($v->id,0))
                              ->limit(12)
                              ->queryAll();
                              ?>
                              <div class="content_box">
                                    <a href="?r=space&id=<?php echo $v->id;?>" title="<?php echo CHtml::encode($v->nickname);?>">
                                          <div class="content_list">
                                                <div class="showbox"> <img src="<?php echo Utils::getAvatar($v->avatar);?>" width="180" height="180" alt="<?php echo CHtml::encode($v->nickname);?>"/>
                                                      <div class="show_main">
                                                            <h3><?php echo CHtml::encode($v->nickname);?></h3>
                                                            <p> <?php echo User::getSex($v->sex),'，',Utils::getAge($v->birth),'，',Area::getName($v->city_id);?><br/>
                                                                  <?php foreach((array)$rs as $k=>$value): ?>
                                                                  <span <?php  if($k===0):?>class="color"<?php endif;?>><?php  echo CHtml::encode($value['tag_name']);?></span>
                                                            <?php endforeach;?>
                                                      </p>
                                                </div>
                                                <div class="alpha_bg1"></div>
                                                <div class="alpha_bg2"></div>
                                                <div class="show_infor">
                                                      <h3><?php echo CHtml::encode($v->nickname);?></h3>
                                                      <p> <?php echo User::getSex($v->sex),'，',Utils::getAge($v->birth),'，',Area::getName($v->city_id);?><br/>
                                                            <?php foreach((array)$rs as $k=>$value): ?>
                                                            <span <?php  if($k===0):?>class="color"<?php endif;?>><?php  echo CHtml::encode($value['tag_name']);?></span>
                                                      <?php endforeach;?>
                                                </p>
                                          </div>
                                    </div>
                              </div>
                        </a>
                  </div>
            <?php endforeach;?>
      <?php else:?>
      <div >没有符合条件的成员</div>
<?php endif;?>
      </div>
</div>
</div>
<div class="page_but">
       <div class="page">
                        <?php $this->widget('ZLinkPager', array('pages' => $users['pages'])); ?>
      </div>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
    var soption='';//保存搜索条件

    $('.define_select').live('click',function(){
      $('#search-form').submit();
});

//     var options = {
//      success: function(data) {$('.content').html(data);}
// };
// $('#search-form').ajaxForm(options);

})

</script>